// RowMajor.java

/*
 * 本类实现行主序的方阵遍历。
 */
public class RowMajor extends SquareTraversal{
    public RowMajor(int size) {
        // 在这里添加代码：
        initiate(size);
    }

    @Override public SquarePoint getInitPoint() {
        // 在这里添加代码：
        return  new SquarePoint(0,0);
    }

    @Override public SquarePoint getNext() {
        // 在这里添加代码：
        SquarePoint currPoint = currentPath.get(currentPath.size() - 1);
        int currRow = currPoint.getRow();
        int currCol = currPoint.getCol();

        int nextRow = 0;
        int nextCol = 0;

        if (currCol < size - 1) {
            nextCol = currCol + 1;
            nextRow = currRow;
        } else {
            if (currRow == size - 1) {
                return null;
            } else {
                nextRow = currRow + 1;
                nextCol = 0;
            }
        }

        SquarePoint nextPoint = new SquarePoint(nextRow, nextCol);
        return nextPoint;
    }
}
